<template>
  <div>
    <!--头部-->
    <div>
      <van-nav-bar :fixed="true">
        <template #left>
          <van-search
              v-model="inputSchoolName"
              show-action
              label="学校"
              placeholder="请输入搜索关键词"
              @search="onSearch"
          >
            <template #action>
              <div @click="onSearch">搜索</div>
            </template>
          </van-search>
        </template>
      </van-nav-bar>
    </div>

  </div>
</template>

<script>
export default {
  name: "HomeHeader",
  data() {
    return {
      inputSchoolName: ''
    }
  },
  methods: {
    onSearch() {
      this.request.get('/api/university/selectByName', {
        params: {
          name: this.inputSchoolName
        }
      }).then(res => {
        //查询到院校的信息，路由跳转，组件之间实现数据共享
        this.$store.dispatch('giveUniList',res.data)
        this.$router.push('/uniList')
      })
    },

  }
}
</script>

<style scoped>

</style>